package com.yiya.service;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yiya.bean.Attribute;
import com.yiya.mapper.AttributeMapper;
import com.yiya.model.AttributeModel;

@Service("AttributeService")
public class AttributeService {
	@SuppressWarnings("unused")
	private final static Logger log = Logger.getLogger(MerchantService.class);

	@Autowired
	private AttributeMapper attributeMapper;
	
	public List<Attribute> queryByList(AttributeModel bean) {
		Integer rowCount = queryByCount(bean);
		bean.getPager().setRowCount(rowCount);
		List<Attribute> attributes = attributeMapper.selectByModel(bean);
		return attributes;
	}
	
	public int queryByCount(AttributeModel bean){
		return attributeMapper.countByModel(bean);
	}
	
	public int add(Attribute attribute){
		return attributeMapper.insert(attribute);
	}
	
	public int Update(Attribute attribute){
		return attributeMapper.updateByPrimaryKeySelective(attribute);
	}
	
	public Attribute queryById(Integer id){
		return attributeMapper.selectByPrimaryKey(id);
	}
	
	public void delete(Integer[] ids){
		for(Integer id:ids){
			attributeMapper.deleteByPrimaryKey(id);
		}
	}
	
	public List<Attribute> queryAllList(AttributeModel bean){
		return attributeMapper.queryAllList(bean);
	}

}
